package com.jquest.data;

import org.newdawn.slick.Graphics;
import com.jquest.editor.Editor;
import com.jquest.misc.Tileset;

/**
 * Created by IntelliJ IDEA.
 * User: Johan
 * Date: 2009-dec-11
 * Time: 03:36:34
 * To change this template use File | Settings | File Templates.
 */
public class Tile implements Renderable {
    public static final int TILE_WIDTH = 32;
    public static final int TILE_HEIGHT = 32;

    private byte tileBlending; //A byte representing tile blending corners and sides

    private int x, y;
    private int imgIdx = -1;

    public Tile(int x, int y, int imgIdx) {
        this.x = x;
        this.y = y;
        this.imgIdx = imgIdx;
    }

    public Tile(int x, int y, int imgIdx, byte tileBlending) {
        this.x = x;
        this.y = y;
        this.imgIdx = imgIdx;
        this.tileBlending = tileBlending;
    }

    public int getImageIndex() {
        return imgIdx;
    }

    public byte getTileBlending() {
        return tileBlending;
    }

    public void update(int time) {
    }

    public void render(Graphics g, Object attachment) {
        if(imgIdx != -1) {
            Tileset ts = (Tileset) attachment;
            //ToDo: fix this, at the moment you need to change the static tileset class to use if you are running Demo, implement TileBlending
            g.drawImage(ts.get(imgIdx), x * TILE_WIDTH, y * TILE_HEIGHT);
        }
    }

}
